package com.module04.work.demo03;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

public class FileCopyCallableImpl implements Callable {

    @Override
    public Object call() throws Exception {
        // 1.创建BufferedInputStream类型的对象与/Users/wanggege/Desktop/模块三资料文件关联
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("/Users/wanggege/Desktop/C/c1/课件.pdf"));
        // 2.创建BufferedOuputStream类型的对象与/Users/wanggege/Desktop/模块三资料2文件关联
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("/Users/wanggege/Desktop/C/c2/课件2.pdf"));
        // 3.不断地从输入流中读取数据并写入到输出流中
        System.out.println("正在玩命的拷贝...");
        byte[] bArr = new byte[1024];
        int res = 0;
        while ((res = bis.read(bArr)) != -1) {
            bos.write(bArr, 0, res);
        }
        System.out.println("文件拷贝成功！");
        // 4.关闭流对象并释放有关的资源
        bos.close();
        bis.close();
        return null;
    }


}
